package com.yswl.yeeduo.ui.bean;

/**
 * 记录分页
 * 
 * @author Administrator
 *
 */
public class Page {
	/** 当前页 **/
	private int currPage = 1; //
	/** 每页多少行 **/
	private int pageSize = 10; //
	/** 共多少行 **/
	private int totalRow; //
	/** 当前页起始行 **/
	private int start;//
	/** 结束行 **/
	private int end;//
	/** 共多少页 **/
	private int totalPage; //

	public int getCurPage() {
		return currPage;
	}

	public void setCurPage(int curPage) {
		if (curPage < 1) {
			curPage = 1;
		} else {
			start = pageSize * (curPage - 1);
		}
		end = start + pageSize > totalRow ? totalRow : start + pageSize;
		this.currPage = curPage;
	}

	public int getStart() {
		// start=curPage*pageSize;
		return start;
	}

	public int getEnd() {
		return end;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalRow() {
		return totalRow;
	}

	public void setTotalRow(int totalRow) {
		totalPage = (totalRow + pageSize - 1) / pageSize;
		this.totalRow = totalRow;
		if (totalPage < currPage) {
			currPage = totalPage;
			start = pageSize * (currPage - 1);
			end = totalRow;
		}
		end = start + pageSize > totalRow ? totalRow : start + pageSize;
	}

	public int getTotalPage() {
		return this.totalPage;
	}

	public boolean canLoadMore() {
		return this.getTotalPage() > currPage;
	}

	public boolean nextPage() {
		if (!canLoadMore())
			return false;
		this.setCurPage(currPage + 1);
		return true;
	}
}